import sys

def check_installation(library_name):
    try:
        __import__(library_name)
        return True
    except ImportError:
        return False

def main():
    print("===== 安装验证脚本 ======")

    # 检查dlib安装
    dlib_installed = check_installation("dlib")
    print(f"dlib 安装状态: {'已安装' if dlib_installed else '未安装'}")

    # 检查face_recognition安装
    face_recognition_installed = check_installation("face_recognition")
    print(f"face_recognition 安装状态: {'已安装' if face_recognition_installed else '未安装'}")

    # 检查cv2安装
    cv2_installed = check_installation("cv2")
    print(f"OpenCV (cv2) 安装状态: {'已安装' if cv2_installed else '未安装'}")

    # 显示版本信息
    if dlib_installed:
        import dlib
        print(f"dlib 版本: {dlib.__version__}")

    if face_recognition_installed:
        import face_recognition
        print(f"face_recognition 版本: {face_recognition.__version__}")

    if cv2_installed:
        import cv2
        print(f"OpenCV 版本: {cv2.__version__}")

    # 提供安装建议
    if not dlib_installed or not face_recognition_installed:
        print("
===== 安装建议 ======")
        print("1. 请参考 INSTALL_FACE_RECOGNITION.md 文档进行手动安装")
        print("2. 确保已安装所有必要的构建工具 (CMake 和 Visual Studio Build Tools)")
        print("3. 优先尝试使用预编译的dlib wheel文件")
        print("4. 安装完成后再次运行此脚本验证")

    print("
验证完成!")

if __name__ == "__main__":
    main()